﻿var outlookbar = new outlook();
var t;


//快捷菜单
t = outlookbar.addtitle('快捷菜单', '快捷导航', 1,'0');
outlookbar.additem('商品管理', t, 'product/product_list.aspx','001008001');
outlookbar.additem('添加会员', t, 'member/member_edit.aspx','008002002');
outlookbar.additem('网站参数配置', t, 'systeminfo/site_setting.aspx','010001007');
outlookbar.additem('商品参数配置', t, 'systeminfo/shop_setting.aspx','010001008');
outlookbar.additem('商品分类管理', t, 'product/productclass_list.aspx?w_d_fatherid=0', '001001001');
outlookbar.additem('会员管理 ', t, 'member/member_list.aspx', '008001001');

//商品管理
t = outlookbar.addtitle('商品管理', '商品管理', 1, '001008001');
outlookbar.additem('商城商品管理', t, 'product/product_list.aspx?q_PutoutType=0', '001008001');
//outlookbar.additem('商家商品管理', t, 'product/product_list.aspx?q_PutoutType=1', '001008001');
outlookbar.additem('仓库商品管理', t, 'product/product_list.aspx?q_PutoutType=2', '001008005');
outlookbar.additem('库存商品管理', t, 'product/product_list.aspx?q_PutoutType=2', '001008001');
outlookbar.additem('商品类型管理', t, 'product/product_type_list.aspx', '001003001');
outlookbar.additem('商品分类管理', t, 'product/productclass_list.aspx?w_d_fatherid=0', '001001001');
outlookbar.additem('商品品牌管理', t, 'product/productbrand_list.aspx', '001002001');
outlookbar.additem('商品单位管理', t, 'product/productunit_list.aspx', '001004001');
//outlookbar.additem('商品批量导入', t, 'product/product_import.aspx', '001005006');
//outlookbar.additem('商品批量导出', t, 'product/product_batch_export.aspx', '001009007');
//outlookbar.additem('商品批量编辑', t, 'product/product_batch_edit.aspx', '001010004');
//outlookbar.additem('淘宝数据导入', t, 'product/product_taobaoimport.aspx', '001006006');
t = outlookbar.addtitle('促销管理', '商品管理', 1, '002001001');
outlookbar.additem('团购商品管理', t, 'product/product_integratepurchas_list.aspx', '002001001');
outlookbar.additem('拍卖商品管理', t, 'product/product_auction_list.aspx', '002002001');
//订单管理
t = outlookbar.addtitle('订单管理', '订单管理', 1, '005001001');
outlookbar.additem('订单管理', t, 'order/order_order_list.aspx', '005001001');
t = outlookbar.addtitle('购物管理', '订单管理', 1, '006001001');
outlookbar.additem('购物车管理', t, 'order/order_shop_list.aspx', '006001001');

t = outlookbar.addtitle('明细记录', '订单管理', 1, '003001001');
outlookbar.additem('资金明细', t, 'product/product_funds_list.aspx', '003001001');
outlookbar.additem('商品销售明细', t, 'product/product_sale_list.aspx', '003002001');
outlookbar.additem('发退货明细', t, 'product/product_back_list.aspx', '003003001');
outlookbar.additem('订单过户明细', t, 'product/product_trans_list.aspx', '003005001');


//用户管理
t = outlookbar.addtitle('管理员', '用户管理', 1, '007001001');
outlookbar.additem('管理员管理', t, 'member/admin_list.aspx', '007001001');
outlookbar.additem('角色管理', t, 'member/role_list.aspx', '007002001');
t = outlookbar.addtitle('会员管理', '用户管理', 1, '008001001');
outlookbar.additem('会员管理', t, 'member/member_list.aspx', '008001001');
outlookbar.additem('无关联门店会员管理', t, 'member/member_list_nostore.aspx', '008001010');
outlookbar.additem('会员等级管理', t, 'member/member_rank_list.aspx', '008003001');
t = outlookbar.addtitle('充值卡管理', '用户管理', 1, '008004001');
outlookbar.additem('充值卡管理', t, 'ordercard/ordercard_list.aspx', '008004001');
outlookbar.additem('未使用的充值卡', t, 'ordercard/ordercard_list.aspx?w_d_whetherRelease=0&w_d_productid=0', '008004001');
outlookbar.additem('已使用的充值卡', t, 'ordercard/ordercard_list.aspx?w_d_whetherRelease=1', '008004001');
var now = new Date();
var year = now.getYear();
var month = now.getMonth() + 1;
var day = now.getDate();
var hour = now.getHours();
var minute = now.getMinutes();
var second = now.getSeconds();
outlookbar.additem('已失效的充值卡', t, 'ordercard/ordercard_list.aspx?w_e_expirationdate=' + year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second, '008004001');
outlookbar.additem('已售出的充值卡', t, 'ordercard/ordercard_list.aspx?w_d_whetherRelease=2&w_n_productid=0', '008004001');
outlookbar.additem('未售出的充值卡', t, 'ordercard/ordercard_list.aspx?w_d_whetherRelease=0&w_n_productid=0', '008004001');
t = outlookbar.addtitle('资金明细', '用户管理', 1, '008005001');
outlookbar.additem('所有资金明细记录', t, 'member/userinandexp_list.aspx?type=all', '008005001');
outlookbar.additem('所有银行收入记录', t, 'member/userinandexp_list.aspx?type=in', '008005001');
outlookbar.additem('所有银行支出记录', t, 'member/userinandexp_list.aspx?type=out', '008005001');
outlookbar.additem('所有已确认的记录', t, 'member/userinandexp_list.aspx?type=sure', '008005001');
outlookbar.additem('所有未确认的记录', t, 'member/userinandexp_list.aspx?type=cancel', '008005001');
outlookbar.additem('所有其他收入记录', t, 'member/capital_rest.aspx?type=in', '008005001');
outlookbar.additem('所有其他支出记录', t, 'member/capital_rest.aspx?type=out', '008005001');
t = outlookbar.addtitle('有效期明细', '用户管理', 1, '008006001');
outlookbar.additem('所有有效期明细记录', t, 'member/member_detail_date.aspx?type=all', '008006001');
outlookbar.additem('所有添加有效期记录', t, 'member/member_detail_date.aspx?type=add', '008006001');
outlookbar.additem('所有扣除有效期记录', t, 'member/member_detail_date.aspx?type=make', '008006001');
t = outlookbar.addtitle('点卷明细', '用户管理', 1, '008007001');
outlookbar.additem('所有点卷明细记录', t, 'member/coupons_record_list.aspx?type=all', '008007001');
outlookbar.additem('所有添加点卷记录', t, 'member/coupons_record_list.aspx?type=in', '008007001');
outlookbar.additem('所有扣除点卷记录', t, 'member/coupons_record_list.aspx?type=out', '008007001');

////店铺管理 
//t = outlookbar.addtitle('店铺管理', '店铺管理', 1, '013003001');
//outlookbar.additem('店铺信息管理', t, 'shop/shop_list.aspx', '013003001');
//outlookbar.additem('店铺类型管理', t, 'shop/shopcategory_list.aspx', '013001001');
//outlookbar.additem('店铺等级管理', t, 'shop/shoplevel_list.aspx', '013002001');
//outlookbar.additem('店铺域名管理', t, 'shop/shop_domain_name.aspx', '013004001');
//outlookbar.additem('店铺公告管理', t, 'shop/shop_affiche_list.aspx', '013005001');
//outlookbar.additem('快速开启店铺', t, 'shop/shop_add.aspx', '013003002');
//t = outlookbar.addtitle('模板标签', '店铺管理', 1, '011001001');
////outlookbar.additem('模型管理',t,'systeminfo/mouldtype_list.aspx?w_d_isstoremould=1');
//outlookbar.additem('店铺模板管理', t, 'shop/shop_color_template.aspx', '011001001');
//outlookbar.additem('店铺标签管理', t, 'templates/label/labelclass_list.aspx?w_d_isstorelabel=1', '011002001');



//资讯频道
t = outlookbar.addtitle('资讯频道', '资讯频道', 1, '009001001');
outlookbar.additem('频道管理', t, 'systeminfo/articlechannel_list.aspx', '009001001');
outlookbar.additem('资讯管理', t, 'systeminfo/article_list.aspx', '009002001');

//模板标签
t = outlookbar.addtitle('模版标签', '模版标签', 1, '011001001');
outlookbar.additem('模板管理', t, 'templates/template.aspx', '011001001');
outlookbar.additem('自由标签管理', t, 'templates/label/freedomlabel_list.aspx', '011003001');

//网站配置
t = outlookbar.addtitle('网站配置', '系统设置', 1, '010001006');
outlookbar.additem('网站参数配置', t, 'systeminfo/site_setting.aspx', '010001006');
outlookbar.additem('商品参数配置', t, 'systeminfo/shop_setting.aspx', '010001008');
outlookbar.additem('用户参数配置', t, 'systeminfo/user_setting.aspx', '010001009');
outlookbar.additem('邮件参数配置', t, 'systeminfo/mail_setting.aspx', '010001010');
outlookbar.additem('缩略图参数配置', t, 'systeminfo/thumbnails_setting.aspx', '010001011');
outlookbar.additem('地区分站配置', t, 'systeminfo/area_setting.aspx?w_d_parentid=0', '010004001');
outlookbar.additem('商城模型管理', t, 'systeminfo/mouldtype_list.aspx?w_d_isstoremould=0', '010005001');
outlookbar.additem('自定义会员注册 ', t, 'member/memberproperty_list.aspx', '001003001');
t = outlookbar.addtitle('银行帐户', '系统设置', 1, '010003001');
outlookbar.additem('银行帐户管理', t, 'systeminfo/bank_list.aspx', '010003001');
outlookbar.additem('银行信息管理', t, 'systeminfo/bankinfo_list.aspx', '010003001');
t = outlookbar.addtitle('其他信息', '系统设置', 1, '010002001');
outlookbar.additem('支付平台管理', t, 'systeminfo/paymentmanage_list.aspx', '010002001');
outlookbar.additem('配送方式管理', t, 'systeminfo/deliver_list.aspx', '004001001');
outlookbar.additem('快递公司管理', t, 'product/express_list.aspx', '004002001');


//附件管理
t = outlookbar.addtitle('广告管理', '附件管理', 1, '012001001');
outlookbar.additem('广告管理', t, 'accessories/advertise_list.aspx', '012001001');
outlookbar.additem('生成JS', t, 'accessories/advertise_createjs.aspx', '012001006');

t = outlookbar.addtitle('数据管理', '附件管理', 1, '012011006');
outlookbar.additem('备份数据库', t, 'accessories/backdatabase.aspx', '012011006');
outlookbar.additem('运行指定的SQL语句', t, 'accessories/exesql.aspx', '012011007');

t = outlookbar.addtitle('信息管理', '附件管理', 1, '012003001');
outlookbar.additem('留言信息管理', t, 'accessories/leaveword_list.aspx', '012003001');
outlookbar.additem('点评信息管理', t, 'product/product_comment_list.aspx', '012005001');

t = outlookbar.addtitle('友情链接', '附件管理', 1, '');
outlookbar.additem('友情链接管理', t, 'accessories/hailhellowlink_list.aspx', '012005001');
outlookbar.additem('添加友情链接', t, 'accessories/hailhellowlink_edit.aspx', '012007002');

t = outlookbar.addtitle('其它信息', '附件管理', 1, '012008001');
outlookbar.additem('缺货登记管理', t, 'accessories/outofstock_list.aspx', '012008001');
outlookbar.additem('收藏管理', t, 'accessories/collection_list.aspx', '012009001');
outlookbar.additem('热门搜索设置', t, 'accessories/topsearchesseting_list.aspx', '012004001');
outlookbar.additem('调查问卷管理', t, 'accessories/questionnaire_list.aspx', '012002001');
outlookbar.additem('评论表单管理', t, 'accessories/commentform_list.aspx', '012005001');
outlookbar.additem('图片管理', t, 'accessories/picturemanaging.aspx', '012010000');

//门店管理
t = outlookbar.addtitle('门店管理', '门店管理', 1, '014001001');
outlookbar.additem('门店管理', t, 'store/store_list.aspx', '014001001')

t = outlookbar.addtitle('销售中心管理', '门店管理', 1, '014002001');
outlookbar.additem('销售中心', t, 'store/storecenter_list.aspx', '014002001');

t = outlookbar.addtitle('消息管理中心', '门店管理', 1, '014003001');
outlookbar.additem('消息管理', t, 'store/storemessage_list.aspx', '014003001');

t = outlookbar.addtitle('留言管理', '门店管理', 1, '014005001');
outlookbar.additem('留言管理', t, 'store/storeask_list.aspx', '014005001');

t = outlookbar.addtitle('联系信息', '门店管理', 1, '014004001');
outlookbar.additem('查看联系信息', t, 'store/contact_view.aspx', '014004001');



//库存管理
t = outlookbar.addtitle('中央仓库', '库存管理', 1, '015001001');
outlookbar.additem('中央仓库', t, 'stocks/stocks_list.aspx', '015001001');
outlookbar.additem('待入库', t, 'stocks/out_stocks_list.aspx', '015001002');
outlookbar.additem('出库', t, 'stocks/out_stocks_Edit.aspx', '015001003');
outlookbar.additem('入库', t, 'stocks/in_stocks_Edit.aspx', '015001004');
outlookbar.additem('商品跟踪', t, 'stocks/product_truck.aspx', '015001005');
outlookbar.additem('订单列表', t, 'stocks/order_list.aspx', '015001006');
t = outlookbar.addtitle('区域中心', '库存管理', 1, '015002001');
outlookbar.additem('区域中心', t, 'stocks/stocks_list.aspx', '015002001');
outlookbar.additem('待入库', t, 'stocks/out_stocks_list.aspx', '015002002');
outlookbar.additem('出库', t, 'stocks/out_stocks_Edit.aspx', '015002003');
outlookbar.additem('入库', t, 'stocks/in_stocks_Edit.aspx', '015002004');
outlookbar.additem('商品跟踪', t, 'stocks/product_truck.aspx', '015002005');
t = outlookbar.addtitle('门店仓库', '库存管理', 1, '015003001');
outlookbar.additem('门店仓库', t, 'stocks/stocks_list.aspx', '015003001');
outlookbar.additem('待入库', t, 'stocks/out_stocks_list.aspx', '015003002');
outlookbar.additem('出库', t, 'stocks/out_stocks_Edit.aspx', '015003003');
outlookbar.additem('入库', t, 'stocks/in_stocks_Edit.aspx', '015003004');
outlookbar.additem('商品跟踪', t, 'stocks/product_truck.aspx', '015003005');
outlookbar.additem('订单列表', t, 'stocks/order_list.aspx', '015003006');

var preClassName = "";

var userRoles = getRoles();
function list_sub_detail(Id, item) {
    if (preClassName != "") {
        getObject(preClassName).className = "left_back"
    }
    if (getObject(Id).className == "left_back") {
        getObject(Id).className = "left_back_onclick";
        outlookbar.getbyitem(item);
        preClassName = Id
    }
}
function getObject(objectId) {
    if (document.getElementById && document.getElementById(objectId)) {
        return document.getElementById(objectId)
    }
    else if (document.all && document.all(objectId)) {
        return document.all(objectId)
    }
    else if (document.layers && document.layers[objectId]) {
        return document.layers[objectId]
    }
    else {
        return false
    }
}
function outlook() {
    this.titlelist = new Array();
    this.itemlist = new Array();
    this.addtitle = addtitle;
    this.additem = additem;
    this.getbytitle = getbytitle;
    this.getbyitem = getbyitem;
    this.getdefaultnav = getdefaultnav
}
function theitem(intitle, insort, inkey, inisdefault,inpermission) {
    this.sortname = insort;
    this.key = inkey;
    this.title = intitle;
    this.isdefault = inisdefault;
    this.permission = inpermission;
}
function addtitle(intitle, sortname, inisdefault,inpermission) {
    outlookbar.itemlist[outlookbar.titlelist.length] = new Array();
    outlookbar.titlelist[outlookbar.titlelist.length] = new theitem(intitle, sortname, 0, inisdefault,inpermission);
    return (outlookbar.titlelist.length - 1)
}
function additem(intitle, parentid, inkey,inpermission) {
    if (parentid >= 0 && parentid <= outlookbar.titlelist.length) {
        insort = "item_" + parentid;
        outlookbar.itemlist[parentid][outlookbar.itemlist[parentid].length] = new theitem(intitle, insort, inkey, 0,inpermission);
        return (outlookbar.itemlist[parentid].length - 1)
    }
    else additem = -1
}
function isInRole(roles,permission){
    var result = false;
    if (roles.length>0 && roles[0]=="all") {
        return true;
    }
    for (ii = 0; ii < roles.length; ii++) {
        if(roles[ii]==permission){
            result = true;
            break;
        }
    }
    return result;
}
function getRoles() {
    var roles = new Array();
    var options = {
        asynchronous: false,
        method: 'get',
        parameters: "option=role",
        onComplete: function (transport) {
            var returnvalue = unescape(transport.responseText);
            if (returnvalue == "all") {
                roles[0] = "all";
            }
            else {
                roles = returnvalue.split(",");
            }
        }
    };
    new Ajax.Request('include/get_server_response.aspx', options);
    return roles;
}
function getdefaultnav(sortname) {
    var output = "";


    for (i = 0; i < outlookbar.titlelist.length; i++) {
        if (outlookbar.titlelist[i].isdefault == 1 && outlookbar.titlelist[i].sortname == sortname) {
            if (outlookbar.titlelist[i].permission == "0" || isInRole(userRoles, outlookbar.titlelist[i].permission)) {

                output += "<div class=list_tilte id=sub_sort_" + i + " onclick=\"hideorshow('sub_detail_" + i + "')\">";
                output += "<span>" + outlookbar.titlelist[i].title + "</span>";
                output += "</div>";
                output += "<div class=list_detail id=sub_detail_" + i + "><ul>";
                for (j = 0; j < outlookbar.itemlist[i].length; j++) {
                    if (isInRole(userRoles, outlookbar.itemlist[i][j].permission)) {
                        output += "<li id=" + outlookbar.itemlist[i][j].sortname + j + " onclick=\"changeframe('" + outlookbar.itemlist[i][j].title + "', '" + outlookbar.titlelist[i].title + "', '" + outlookbar.itemlist[i][j].key + "')\"><a href=#>" + outlookbar.itemlist[i][j].title + "</a></li>"
                    }
                }
                output += "</ul></div>"
            }
        }
    }
    getObject('right_main_nav').innerHTML = output
}

function getbytitle(sortname) {
    var output = "<ul>";
    for (i = 0; i < outlookbar.titlelist.length; i++) {
        if (outlookbar.titlelist[i].sortname == sortname) {
            if (outlookbar.titlelist[i].permission=="0" || isInRole(userRoles, outlookbar.titlelist[i].permission)) {
                output += "<li id=left_nav_" + i + " onclick=\"list_sub_detail(id, '" + outlookbar.titlelist[i].title + "')\" class=left_back>" + outlookbar.titlelist[i].title + "</li>"
            } 
        }
    }
    output += "</ul>";
    getObject('left_main_nav').innerHTML = output
}
function getbyitem(item) {
    var output = "";
    for (i = 0; i < outlookbar.titlelist.length; i++) {
        if (outlookbar.titlelist[i].title == item) {
            output = "<div class=list_tilte id=sub_sort_" + i + " onclick=\"hideorshow('sub_detail_" + i + "')\">";
            output += "<span>" + outlookbar.titlelist[i].title + "</span>";
            output += "</div>";
            output += "<div class=list_detail id=sub_detail_" + i + " style='display:block;'><ul>";
            for (j = 0; j < outlookbar.itemlist[i].length; j++) {
                output += "<li id=" + outlookbar.itemlist[i][j].sortname + "_" + j + " onclick=\"changeframe('" + outlookbar.itemlist[i][j].title + "', '" + outlookbar.titlelist[i].title + "', '" + outlookbar.itemlist[i][j].key + "')\"><a href=#>" + outlookbar.itemlist[i][j].title + "</a></li>"
            }
            output += "</ul></div>"
        }
    }
    getObject('right_main_nav').innerHTML = output
}
function changeframe(item, sortname, src) {
    if (item != "" && sortname != "") {
        window.top.frames['mainFrame'].getObject('show_text').innerHTML = sortname + "  <img src=images/slide.gif broder=0 />  " + item
    }
    if (src != "") {
        window.top.frames['manFrame'].location = src
    }
}
function hideorshow(divid) {
    subsortid = "sub_sort_" + divid.substring(11);
    if (getObject(divid).style.display == "none") {
        getObject(divid).style.display = "block";
        getObject(subsortid).className = "list_tilte"
    }
    else {
        getObject(divid).style.display = "none";
        getObject(subsortid).className = "list_tilte_onclick"
    }
}
function initinav(sortname) {
    outlookbar.getdefaultnav(sortname);
    outlookbar.getbytitle(sortname);
    document.getElementById("right_main_nav").style.height = document.documentElement.clientHeight - 68;
}